package com.logic.adapter;

import android.graphics.Color;
import android.widget.TextView;

import com.sinopec.basemodule.adapter.newadapter.BaseRecyclerViewAdapter;
import com.sinopec.basemodule.adapter.viewholder.BaseViewHolder;
import com.sinopec.basemodule.constants.NoDataTypeEnum;
import com.uhf.uhf.R;

import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
 * 创建人：lwj<br/>
 * 创建时间：2019/8/15 14:32 <br/>
 */
public class RfidAdapter extends BaseRecyclerViewAdapter<String> {


    public interface Callback {
        void calculateNumber();
    }

    private List<String> mItemList;

    public RfidAdapter(List<String> itemList) {
        super(R.layout.item_rfid, itemList, NoDataTypeEnum.NO_DATA);
        mItemList = itemList;
    }


    @Override
    public void convert(@NotNull BaseViewHolder holder, String model, int position) {

        //位置信息从1开始
        int newPosition = position + 1;
        int bgIndex = newPosition % 2;
        if (bgIndex == 1) {
            holder.itemView.setBackgroundColor(Color.WHITE);
        } else {
            holder.itemView.setBackgroundColor(Color.parseColor("#F6F7FA"));
        }

        //设置id
        TextView idTv = holder.getView(R.id.id_tv);
        idTv.setText(newPosition + "");

        //设置托盘code
        TextView codeTv = holder.getView(R.id.code_tv);
        codeTv.setText(model);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, String operateTagMap, @NotNull List<Object> payloads) {
        super.convert(holder, operateTagMap, payloads);
        //位置信息从1开始
        int newPosition = holder.getBindingAdapterPosition() + 1;
        int bgIndex = newPosition % 2;
        if (bgIndex == 1) {
            holder.itemView.setBackgroundColor(Color.WHITE);
        } else {
            holder.itemView.setBackgroundColor(Color.parseColor("#F6F7FA"));
        }
        //设置id
        TextView idTv = holder.getView(R.id.id_tv);
        idTv.setText(newPosition + "");
    }

}
